package Control;

import javax.swing.JOptionPane;

import Entity.MsgPackage;
import GUI.DetermineDurationGui;
import GUI.ScreenManager;

public class DetermineDuration {
	
	private DetermineDurationGui dete_dur;
	private MsgPackage durMsg; 
	private String[] dur_data;
	
	public DetermineDuration()
	{
		dete_dur = new DetermineDurationGui();
		durMsg = new MsgPackage();
		dur_data = new String[4];
		for(int i =0; i<dur_data.length;i++)
			dur_data[i]= null;
	}
	
	
	public void submit_pressed(){
		dur_data[0] = (String) dete_dur.getComboBox_1().getSelectedItem();
		dur_data[1] = (String)dete_dur.getComboBox_2().getSelectedItem();
		dur_data[2] = (String)dete_dur.getComboBox_3().getSelectedItem();
		dur_data[3] = (String)dete_dur.getComboBox_4().getSelectedItem();
		for(int i =0 ;i<dur_data.length;i++)
			if(dur_data[i]==null){
				JOptionPane.showMessageDialog(null, "**Not all fields are filled**", "Error", JOptionPane.ERROR_MESSAGE);  
				} 

			else
		
		durMsg.setObject(dur_data);
		durMsg.setObject(OP_CODE.DETERMINE_DURATION);
		ScreenManager.getConnection().accept(durMsg);//send the msg to the server
	}

	public DetermineDurationGui getDete_dur() {
		return dete_dur;
	}

	public void setDete_dur(DetermineDurationGui dete_dur) {
		this.dete_dur = dete_dur;
	}

}
